<?php

namespace app\data\model;

use app\data\model\ActArticleCommentModel;
use think\admin\Model;

/**
 * 活动文章模型
 */
class ActArticleModel extends Model
{
    protected $table = 'data_article_show_activity';
    const IS_BEST_TRUE = 1;
    const DEFAULT_LOGO = '/public/activity/images/activity_default.jpg';

    //logo地址自适应
    public function getLogoAttr($value)
    {
        return $value ?: self::DEFAULT_LOGO;
    }

    //添加评论
    public function addComment($data,$create_user_id)
    {
        $data['article_id'] = $this->id;
        $data['create_user_id'] = $create_user_id;
        return ActArticleCommentModel::create($data);

    }

    public function visitInc()
    {
        $this->read_count++;
        return $this->save();
    }

}